package chances.wechat.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;

import chances.framework.ufs.UserFileSystem;

@Configuration
@ComponentScan(basePackages = "chances.wechat")
@PropertySource("/WEB-INF/conf/wechat-gateway.properties")
public class GatewayConfig extends WebMvcConfigurationSupport {

	@Value("${wechat.user.root}")
	private Resource userFileRoot; 
	
	@Bean
	public InternalResourceViewResolver getInternalResourceViewResolver() {
		InternalResourceViewResolver resolver = new InternalResourceViewResolver();
		resolver.setViewClass(JstlView.class);
		resolver.setPrefix("/WEB-INF/weixin");
		return resolver;
	}
	
	@Bean
	UserFileSystem userFileSystem (){
		return new UserFileSystem(this.userFileRoot);
	}; 
}
